package com.yiyuan.common.base;

import java.sql.Timestamp;
import java.util.Date;
import java.util.Map;

import org.apache.struts2.interceptor.SessionAware;

import com.opensymphony.xwork2.ActionSupport;
import com.yiyuan.system.model.User;

public class BaseAction extends ActionSupport implements SessionAware {
	private static final long serialVersionUID = 1L;
	private User user;
	protected Map<String, Object> session;

	public void setSession(Map<String, Object> session) {
		this.session = session;
	}

	public User getUser() {
		if (session != null) {
			user = (User) session.get("user");
		}
		return user;
	}

	public Integer getSessionUserId() {
		Integer userId = null;
		if (this.getUser()!= null) {
			userId =this.getUser().getUserId();
		}
		return userId;
	}

	public Timestamp getCreateTime(){
		Date curDateTime = new Date();
		Timestamp curTime = new Timestamp(curDateTime.getTime());
		return curTime;
	}
}
